home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / SHARED.DIR / 03087_Script_TRANSITIONS < prev    next >
Text File  |  1996-04-01  |  2KB  |  51 lines

  1. -- -----------------------------------------------------------
  2. -- Handler getTransitionNumber returns the number of the given
  3. -- doTransition. This version uses binary search.
  4.  
  5. on getTransitionNumber whichTransition
  6.   set allTransitions = field "Transitions"
  7.   
  8.   set transitionLine = binSearchFirstItemInLine(allTransitions, whichTransition, ":")
  9.   
  10.   -- Error Handling
  11.   if (transitionLine = 0) then
  12.     errorAlert("TRANSITION NOT FOUND")
  13.   end if
  14.   
  15.   set the itemDelimiter = ":"
  16.   set transitionNumber = value(item 2 of line transitionLine of allTransitions)
  17.   
  18.   set the itemDelimiter = ";"
  19.   return transitionNumber
  20. end
  21.  
  22. -- -----------------------------------------------------------
  23. -- Handler doTransition performs the given doTransition
  24. -- in the given time.
  25.  
  26. on doTransition whichTransition, time, chunkSize
  27.   put getTransitionNumber(whichTransition) into theTransition
  28.   
  29.   if voidP(chunkSize) then
  30.     puppetTransition theTransition, time
  31.   else
  32.     puppetTransition theTransition, time, chunkSize
  33.   end if
  34. end
  35.  
  36. -- -----------------------------------------------------------
  37. -- setting up the transition field.
  38.  
  39. on sortField whichField
  40.   set unsortedData = field whichField
  41.   set sortedData = []
  42.   repeat with i = 1 to the number of lines in unsortedData
  43.     set currentLine = line i of unsortedData
  44.     add (sortedData, currentLine)
  45.   end repeat
  46.   sort sortedData
  47.   
  48.   repeat with i = 1 to count(sortedData)
  49.     put getAt(sortedData,i) into line i of field whichField
  50.   end repeat
  51. end